//
//  VisitorObjects.h
//  Charles
//
//  Created by Leo on 2019/7/15.
//  Copyright © 2019 charles. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@class VFile,VDirectory;
/**
 表示访问者的抽象类
 */
@protocol Visitor <NSObject>
@optional
- (void)visitFile:(VFile *)file;

- (void)visitDirectory:(VDirectory *)directory;

@end

/**
 表示接受访问者的访问的接口
 */
@protocol Element <NSObject>
@optional
- (void)accept:(id<Visitor>)visitor;

@end

/**
 表示目录条目的抽象类
 */
@interface VEntry : NSObject<Element>

- (NSString *)getName;
- (NSInteger)getSize;
- (VEntry *)add:(VEntry *)entry;
- (void)printList;
- (void)printList:(NSString *)prefix;
- (NSString *)toString;

@end

/**
 文件类
 */
@interface VFile : VEntry

- (instancetype)initWithName:(NSString *)name size:(NSInteger)size;

@end

/**
 目录类
 */
@interface VDirectory : VEntry

- (instancetype)initWithName:(NSString *)name;

@property (nonatomic, strong) NSMutableArray *directory;

@end

/**
 访问数据结构并显示元素一览
 */
@interface ListVisitor : NSObject<Visitor>

@end

NS_ASSUME_NONNULL_END
